arr = [[1, 91],
       [2, 84],
       [2, 94],
       [2, 80],
       [2, 87],
       [2, 86],
       [3, 76],
       [3, 84],
       [1, 94],
       [1, 86],
       [1, 90],
       [2, 85],
       [2, 90],
       [2, 94],
       [2, 89],
       [3, 90]]

print(len(arr))


def gpa_calculate(mark_list):
    """计算GPA"""
    mark_sum = 0
    weight_sum = 0
    for mark in mark_list:
        mark_sum = mark_sum + mark[0]*mark[1]
        weight_sum = weight_sum + mark[0]
    gpa = (mark_sum*4) / (weight_sum*100)       # 成绩的加权平均数乘以4，再除以100
    return gpa


print(gpa_calculate(arr))
